package com.rc.saas.mini.component;

/**
 * @Author: zcg
 * @CreateDate: 2022/4/28 9:22
 */
//全局异常捕获方法

import com.rc.saas.mini.common.base.TResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;

/**异常处理类
 * @author Administrator
 */
@RestControllerAdvice
public class MiniExceptionsHandler {
    private static Logger logger = LogManager.getLogger(MiniExceptionsHandler.class);
    @ExceptionHandler(value = Exception.class)
    TResponse handlerException(Exception e, HttpServletRequest request) {
        logger.info("地址：{}:{}",request.getServletPath(),e.getMessage());
        e.printStackTrace();
        return TResponse.FAIL("服务器内部异常:"+e.getMessage());
    }
}
